/**
 * Created by Administrator on 2017/6/14.
 */
import React from 'react';
import
{
    View,
    Text,
    TouchableHighlight,
    TouchableOpacity,
    Image,
    ListView,
    StyleSheet,
}
    from 'react-native';
import  BaseComponent, {base} from '../../../base/Base' ;
let {CategoryGoods_1019} =base.requests ;
export default class LifeServerSecondList extends BaseComponent {
    constructor(props) {
        super(props);
        var ds =new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
        this.state = {
            dataSource: ds.cloneWithRows(this.props.navigation.state.params.dataList),
        };
    }
    componentDidMount() {
        console.info(this.state.dataList)
    }
    //跳转到其他页面
    _jumpToOtherPage(lable,params){
        this.props.navigation.navigate(lable,params);
    }
    _pressRow(rowID,rowData){
        // console.log(rowData);
        this._jumpToOtherPage('GoodsDetailPage',{goodId:rowData['goodsId'],title:rowData['goodsName']});
    }
    _renderRow(rowData, sectionID, rowID){
        return (
            <TouchableOpacity onPress={()=>this._pressRow(rowID,rowData)} style={styles.container}>
                <View style={{flex:1,flexDirection:'row',}}>
                    <Image source={{uri: rowData['iconUrl']}} style={styles.image}></Image>
                    <View style={styles.parent}>
                        <View style={styles.view}>
                            <Text style={styles.textDetail}>{rowData['goodsName']}</Text>
                            <Text style={styles.text}>￥{rowData['discountPrice']}</Text>
                        </View>
                        <View style={styles.view}>
                            <Text style={styles.source}>{/*{rowData['remark']}*/}舒适&nbsp;安逸</Text>
                        </View>
                    </View>
                </View>
                <View style={{width:'100%',height:1,backgroundColor:'#dedede'}}></View>
            </TouchableOpacity>
        );
    }
    static navigationOptions = ({navigation}) => ({
        title:navigation.state.params.title,
    });
    render() {
       return (
           <View style={{flex:1}}>
               <ListView
                   enableEmptySections={true}
                   dataSource={this.state.dataSource}
                   renderRow={this._renderRow.bind(this)}
               />
           </View>
       )
    }
}
var styles=StyleSheet.create({
    container:{
        height:140,
        flexDirection:'column',
        justifyContent:'center',
        backgroundColor:'#fff',
        borderRadius:5,
        padding:20,
        paddingBottom:0,
    },
    parent:{
        flex:1,
        flexDirection:'column',
        justifyContent:'center',
        paddingLeft:20,
    },
    image:{
        width:100,
        height:100,
        padding:10,
    },
    view:{
        flex:1,
        flexDirection:'row',
    },
    text:{
        flex:1,
        flexDirection:'row',
        fontSize:18,
        color:"#ff5658",
        textAlign:'right'
    },
    textDetail:{
        flexDirection:'row',
        flex:3,
        fontSize:18,
        color:"#212121",
    },
    source:{
        flexDirection:'row',
        flex:3,
        fontSize:16,
        color:"#808080",
    }
})
